package calendar;

import java.awt.* ;
import java.awt.event.* ;
import javax.swing.* ;
import javax.swing.event.DocumentListener;

/* this class provides an input panel for user text input */
public class TextInputPanel extends JPanel implements ActionListener
{
  private static final long serialVersionUID = 3439048230L;

  JTextField textField ;

  public TextInputPanel ( String labelStr, int maxCharacters )
  {
    setLayout ( new BoxLayout( this, BoxLayout.X_AXIS ) ) ;

    JLabel label = new JLabel ( labelStr ) ;
    label.setFont (  new Font( "Dialog", Font.BOLD, 12  ) );

    textField = new JTextField ( maxCharacters ) ;
    textField.setFont (  new Font( "Dialog", Font.BOLD, 12 ) ) ;

    add ( label ) ;
    add ( Box.createHorizontalStrut( 10 ) );
    add ( textField ) ;
  }

  public void setEditable ( boolean isEditable )
  {
    textField.setEditable ( isEditable ) ;
  }

  public String getText ()
  {
    String fileSet = textField.getText () ;
    return fileSet ;
  }

  public void clear()
  {
    textField.setText("");
  }

  public void setText( String text )
  {
    textField.setText( text );
  }

  void addDocumentListener ( DocumentListener listener )
  {
    textField.getDocument().addDocumentListener ( listener ) ;
  }

  void removeDocumentListener ( DocumentListener listener )
  {
    textField.getDocument().removeDocumentListener ( listener ) ;
  }

  public void actionPerformed(ActionEvent e)
  {
    throw new UnsupportedOperationException("Not supported yet.");
  }
}

